// 对接口进行统一管理
import requests from "./request";

// 虽然是请求mockServer，但是请求方式还是axios，因此也就有.get方法
import mockRequests from "./mockRequest";

// 三级联动接口
// http://39.98.123.211/api/product/getBaseCategoryList GET
// 通过函数的形式,将这个接口暴露出去,方便其他模块使用
export const reqCategoryList = () =>
  requests.get(
    // requests已经有baseURL了，前面不需要再加api了
    "/product/getBaseCategoryList"
  );

export const reqBannerList = () => mockRequests.get("/banner");

export const reqFloorList = () => mockRequests.get("/floors");

// post请求，还带参数，因为搜索时需要提交用户的输入内容
export const reqSearchInfo = (params) => requests.post("/list", params);

export const reqGoodsInfo = (skuId) => requests.get(`/item/${skuId}`);

// export const reqAddOrUpdateShopCart = (skuId, skuNum) => (requests.post(`/cart/addToCart/${skuId}/${skuNum}`))

export const reqAddOrUpdateShopCart = (skuId, skuNum) =>
  requests.post(`/cart/addToCart/${skuId}/${skuNum}`);

export const reqShopCartList = () => requests.get("/cart/cartList");

// /api/cart/deleteCart/{skuId}
export const reqDeleteShopCart = (skuId) =>
  requests.delete(`/cart/deleteCart/${skuId}`);

// /api/cart/checkCart/{skuID}/{isChecked}
export const reqUpdateCheckedById = (skuId, isChecked) =>
  requests.get(`/cart/checkCart/${skuId}/${isChecked}`);

// /api/user/passport/sendCode/{phone}
export const reqGetCode = (phone) =>
  requests.get(`/user/passport/sendCode/${phone}`); 

  // /api/user/passport/register post: phone password code

export const reqRegister = (data) =>
  requests.post(`/user/passport/register`,data); 